package com.gsafety.wellsfort.controller.knowledge;

import com.gsafety.wellsfort.common.util.ApiResponse;
import com.gsafety.wellsfort.domain.dto.ids.KnowledgePointIdDTO;
import com.gsafety.wellsfort.domain.dto.knowledgepoint.KnowledgePointDTO;
import com.gsafety.wellsfort.domain.dto.knowledgepoint.KnowledgePointQueryDTO;
import com.gsafety.wellsfort.domain.vo.KnowledgePointVO;
import com.gsafety.wellsfort.service.knowledge.KnowledgePointService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "知识点管理",description = "知识点管理接口")
@RestController
@Slf4j
@RequestMapping("/api/kpoint")
public class KnowledgePointController {
    @Autowired
    private KnowledgePointService knowledgePointService;
    @ApiOperation(value="保存知识点")
    @PostMapping("/save")
    public ApiResponse<KnowledgePointDTO> saveKnowledgePoint(@RequestBody KnowledgePointDTO qDto){
        return knowledgePointService.saveKnowledgePoint(qDto);
    }

    @ApiOperation(value="删除知识点")
    @PostMapping("/delete")
    public ApiResponse deleteKnowledgePoint(@RequestBody KnowledgePointIdDTO idDTO){
        return knowledgePointService.deleteKnowledgePoint(idDTO.getKnowledgePointId());
    }

    @ApiOperation(value="编辑知识点")
    @PostMapping("/get")
    public ApiResponse<KnowledgePointVO> getKnowledgePoint(@RequestBody KnowledgePointIdDTO idDTO){
        return knowledgePointService.getKnowledgePoint(idDTO.getKnowledgePointId());
    }

    @ApiOperation(value="查询知识点")
    @PostMapping("/list")
    public ApiResponse<List<KnowledgePointVO>> findByPageParams(@RequestBody KnowledgePointQueryDTO dtoParams){
        return knowledgePointService.findByPageParams(dtoParams);
    }
}
